#!/usr/bin/env python3.3

#
#  Filename: e41.py
#  Author  : lukas singer
#
#  Comment : Created by createSolution.sh
#

#import euler
from euler import isPrime
from itertools import permutations

def pe41():
  s="123456789"
  for i in range(9,0,-1):
    m=0
    for t in permutations(s[:i]):
      n=int(''.join(t))
      if isPrime(n):
        if n>m:
          m=n
    if m>0:
      print(m)
      break

if __name__=="__main__":
  pe41()

